<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 引入 vue.js 文件 -->
    <script src="../js/vue.js"></script>
    <style>
        #app div {
            float: left;
            width: 50px;
            height: 50px;
            line-height: 50px;
            background-color: bisque;
            text-align: center;
            margin-left: 10px;
        }
    </style>
</head>

<body>
    <div id="app">
        <h2>当前计数:{{counter}} </h2>
        <div @click="sub">-</div>
        <div @click="add">+</div>
    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                counter: 0
            },
            // 事件函数
            methods: {
                add: function () {
                    this.counter++;
                },
                sub: function () {
                    this.counter--;
                }
            }
        });
    </script>
</body>

</html>